/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.commands;

import org.jfonia.model.ISequence;
import org.jfonia.model.elements.MusicalElement;

/**
 *
 * @author Rik Bauwens
 */
public class RemoveMusicalElementCommand extends Command
{
        private ISequence sequence;
        private int tick;
        private MusicalElement musicalElement;

        public RemoveMusicalElementCommand(ISequence sequence, MusicalElement musicalElement)
        {
                super();
                this.sequence = sequence;
                this.tick = musicalElement.getBegin();
                this.musicalElement = musicalElement.clone();
        }

        @Override
        protected void execute()
        {
                sequence.removeMusicalElement(sequence.getMusicalElement(tick));
        }

        @Override
        protected void undo()
        {
                sequence.insertMusicalElement(tick, musicalElement.clone());
        }
}
